<?php 
  // Start the SESSION vars
	if (session_id() == "")
	{
		session_start();
	}
	// Include configuration variables
  include_once('/var/www/gde-1.0/htdocs/config.php');
  //Include the login top.php
  include_once(Config::base_path.Config::top_login_php); 
  // Include the login nav.php
  include_once(Config::base_path.Config::nav_login_php); 
   // Include builder functions
  include_once(Config::base_path.Config::builder_func_path."builder.func.php");
  
  // Query must be lenght > 0
  if(strlen($_POST['editor']) != 0)
  {
    // Set the query string to the session variable from the editor
    $_SESSION['editor'] = $_POST['editor'];
  
    //record2PagingHtml_2($_SESSION['editor'],4); // can use this but need to fix the session var
    
    // Use the query string posted from editor.php to execute a query
    $database_connection = db_pconnect(Config::db_type,Config::db_host,$_SESSION['username'],$_SESSION['password'],$_SESSION['selected_database'],Config::errors);
	  $pager = new ADODB_Pager($database_connection,stripslashes($_SESSION['editor']),'self',true);
	  $pager->Render(5);
	  
	  // Alternate way to print the results (no paginating)
    //$result_ans = $database_connection->Execute(stripslashes($_SESSION['editor']));
    //record2Html($result_ans);
  }
  else 
  {
    message2html("An SQL query must be valid!",red,center);
    message2html("You will be redirected",black);
    message2redirect("","/gde-1.0/templates/logged-in/editor.php",3);
  }
?>